package com.livi.tools.cas_general_backend.config.cas;

import net.unicon.cas.client.configuration.CasClientConfigurerAdapter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CasConfiguration extends CasClientConfigurerAdapter {

    @Override
    public void configureAuthenticationFilter(FilterRegistrationBean authenticationFilter) {
        super.configureAuthenticationFilter(authenticationFilter);
        // 配置地址，这里还可以配置很多，例如cas重定向策略等。
        authenticationFilter.getInitParameters().put("ignorePattern", "/index|/index.html|/assets|/auth/cas|/auth/logout|/test");
        authenticationFilter.getInitParameters().put("authenticationRedirectStrategyClass",
                "com.livi.tools.cas_general_backend.config.cas.CustomAuthenticationRedirectStrategy");
    }

    @Override
    public void configureValidationFilter(FilterRegistrationBean validationFilter) {
        validationFilter.getInitParameters().put("encodeServiceUrl", "false");
    }
}